package com.example.streamdemo.consumer;

import com.example.streamdemo.bean.Person;
import com.example.streamdemo.channel.MyInputChannel;
import com.example.streamdemo.channel.MyOutputChannel;
import com.example.streamdemo.channel.NewChannel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;

/**
 * @Package: com.example.streamdemo.consumer
 * @ClassName: MyMessageConsumer
 * @Author: Think
 * @CreateTime: 2021/7/16 8:33
 * @Description:
 */
@Slf4j
@Component
@EnableBinding(NewChannel.class)
public class MyMessageConsumer3 {

    @StreamListener(value = NewChannel.INPUT, condition = "headers['MyTag']=='TAG2'")
    public void receive(Message<Person> message){
        log.info("MyMessageConsumer3监听到消息内容为：{}", message);
        log.info("MyMessageConsumer3消息的payload:{}", message.getPayload());
        log.info("MyMessageConsumer3消息的header:{}", message.getHeaders().get("MyTag"));
    }

}
